package experiment1;

import java.lang.Math;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by pc on 4/8/16.
 */
public class Prime {

    static int n;
    static int primeNum;
    static int[] prime;

    static int listLength = 100;

    public Prime(int n) {
        this.n = n;
        prime = new int[listLength];

    }

    public int[] getAllPrime() {
        if (n < 2) {
            return null;
        }
        primeNum = 0;
        for (int i = 2; i <= n; i++) {
            boolean flag = true;
            for (int j = 2; j <= (int)Math.sqrt(i); j++) {
                if (i % j == 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                prime[primeNum++] = i;
            }
        }
        return prime;
    }

    public static int getPrimeNum() {
        return primeNum;
    }


}